import React, { useEffect, useState, useRef } from 'react';
import { View, Text, Dimensions, Animated, Easing, Button } from 'react-native';
import DanmakuView from 'react-native-android-danmaku';

const sw = Dimensions.get('window').width;
const sh = Dimensions.get('window').height;



function FlipWords() {
    let danmu = useRef<any>(null);

    useEffect(() => {
        let count = 0;
        if(danmu){
            danmu.current.show();
        }
        let inte =setInterval(() => {
            add();
            count+=1;
            if(inte > 5000) clearInterval(inte)
        },2)
    }, [danmu.current])

    function add(){
        if(danmu){
            // console.log("加")
            danmu.current.addDanmaku({
                text: Math.round(Math.random()*1000).toString(),
                color: "black",
                padding: 3,
                time:1000,
                fontSize:40,
                isLive:true
            })
            // danmu.current.show();
        }

    }


    return (
        <View style={{ height: "100%", width: '100%' }}>
            <DanmakuView
                style={{ width: sw, height: sh*0.8 }}
                maxLines={50}
                ref={danmu}
                speed={1.1}
            />
        </View>
    )
}
export default FlipWords;